var bind_out = "body";
function sisBindInterval(e, tipo) {
    var fun = $(e).attr(tipo);
    if (fun != undefined) {
        var pagina = $(e).attr("page");
        if (pagina == undefined) {
            pagina = ""
        }
        var sisfunHAppyyyy = formData($(e).parents("form:eq(0),tr:eq(0)"));
        var funName = part(fun, "(")[0];
        var atrStr = part(part(fun, "(")[1], ")")[0];
        var atrs = part(atrStr, ",");
        atrStr = "";
        for (i = 0; i < atrs.length; i++) {
            var v = atrs[i];
            eval("sisfunHAppyyyy.post" + i + ' = "' + v + '";')
        }
        if ($(e).attr("lock") != undefined) {
            lock(e)
        }
        sisfunHAppyyyy.pkjCMDPAGE = pagina;
        sisfunHAppyyyy.pkjCMDWWW = funName;
        $.post("", sisfunHAppyyyy, function (resp) {
            if (len(trim(resp)) > 0) {
                try {
                    eval(resp);
                } catch (e) {
                    console.log(e);
                }
            }
            if ($(e).attr("lock") != undefined) {
                lock(e)
            }
        })
    }
    return true
}
function sisBindRequest() {
    setTimeout(function () {
        $.each($("input,select,a,button,img,textarea"), function (e, t) {
            if ($(t).attr("bind") == undefined) {
                var n = "";
                if ($(t).attr("keyup") != undefined) {
                    n = "keyup";
                    $(t).keyup(function () {
                        sisBindInterval(t, n)
                    }).attr("bind", true)
                }
                if ($(t).attr("keydown") != undefined) {
                    n = "keydown";
                    $(t).keydown(function () {
                        sisBindInterval(t, n)
                    }).attr("bind", true)
                }
                if ($(t).attr("keypress") != undefined) {
                    n = "keypress";
                    $(t).keypress(function () {
                        sisBindInterval(t, n)
                    }).attr("bind", true)
                }
                if ($(t).attr("blur") != undefined) {
                    n = "blur";
                    $(t).blur(function () {
                        sisBindInterval(t, n)
                    }).attr("bind", true)
                }
                if ($(t).attr("click") != undefined) {
                    n = "click";
                    $(t).click(function () {
                        sisBindInterval(t, n)
                    }).attr("bind", true)
                }
                if ($(t).attr("change") != undefined) {
                    n = "change";
                    $(t).change(function () {
                        sisBindInterval(t, n)
                    }).attr("bind", true)
                }
            }
        })
    }, 128)
}
$(function () {
    $.post("", {pkjCMDWWW: "init", atrs: ""}, function (resp) {
        if (len(trim(resp)) > 0) {
            setTimeout(function () {
                try {
                    eval(resp);
                } catch (e) {
                    if (substring(trim(bind_out), 0, 1) == "." || substring(trim(bind_out), 0, 1) == "#") {
                        $(bind_out).html(resp);
                    } else {
                        $(bind_out).append(resp);
                    }
                }
            }, 128)
        }
    });
    sisBindRequest()
});
function bindCall(pagina, funcao) {
    var parametros = new Object;
    var funName = part(funcao, "(")[0];
    var atrStr = part(part(funcao, "(")[1], ")")[0];
    var atrs = part(atrStr, ",");
    atrStr = "";
    for (i = 0; i < atrs.length; i++) {
        var v = atrs[i];
        eval("parametros.post" + i + ' = "' + v + '";')
    }
    parametros.pkjCMDWWW = funName;
    parametros.pkjCMDPAGE = pagina;
    $.post(pagina, parametros, function (resp) {
        if (len(trim(resp)) > 0) {
            try {
                eval(resp);
            } catch (e) {
                if (substring(trim(bind_out), 0, 1) == "." || substring(trim(bind_out), 0, 1) == "#") {
                    $(bind_out).html(resp);
                } else {
                    $(bind_out).append(resp);
                }
            }
        }
    })
}
